<!--GoodsList.html-->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css" crossorigin="anonymous">
    <title>订单列表</title>
    <style>
        body{
            margin:0;
            padding:0;
            height: 100vh;
            display: flex;
            flex-direction: column;
        }
        .main-container{
            display: flex;
            flex: 1;
        }
        aside{
            width: 190px;
            background-color: #171d1d;
        }
        .right-container{
            display: flex;
            flex: 1;
            flex-direction: column;
            background-color: #ffffff;
        }
        header{
            min-height: 60px;
            text-align: center;
            padding: 10px;
            margin-bottom: 25px;
            box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        }
        .main-content {
            flex: 1;
            padding: 10px;
            overflow-y: auto;
        }
        .content-card {
            background-color: white;
            box-shadow: 0 5px 10px rgba(0,0,0,0.1);
            padding: 15px;
            margin-bottom: 15px; /* 调整与表格的间距 */
        }
        .table {
            box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        }
        .table a:hover {
            text-decoration: none;
        }

    </style>
</head>
<body>
    <div class="main-container">

        <aside th:replace="~{/layout/left_menu.html}"></aside>

        <div class="right-container">

            <header th:replace="~{/layout/header.html}"></header>

            <div class="main-content">
                <div class="content-card">
                    <button type="button" class="btn btn-primary" onclick="addGoods()">
                        新增Goods
                    </button>
                </div>
                <table class="table">
                    <thead class="thead-dark">
                    <tr>
                        <th scope="col">id</th>
                        <th scope="col">name</th>
                        <th scope="col">price</th>
                        <th scope="col">description</th>
                        <th scope="col">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="goods : ${goodsList}">
                        <td th:text="${goods.id}"></td>
                        <td th:text="${goods.name}"></td>
                        <td th:text="${goods.price}"></td>
                        <td th:text="${goods.description}"></td>

                        <th>
                            <a th:href="@{/Goods/toEdit(id=${goods.id})}">修改</a>
                            <a th:href="@{/Goods/remove(id=${goods.id})}">删除</a>
                        </th>
                    </tr>
                    </tbody>
                </table>
                <nav aria-label="Page navigation example">
                    <ul class="pagination">
                        <li class="page-item">
                            <a class="page-link" th:href="@{/Goods/list/{currentPage}/3(currentPage = ${currentPage}-1)}">上一页</a>
                        </li>
                        <li class="page-item"><a class="page-link" th:href="@{/Goods/list/1/3}">1</a></li>
                        <li class="page-item"><a class="page-link" th:href="@{/Goods/list/2/3}">2</a></li>
                        <li class="page-item"><a class="page-link" th:href="@{/Goods/list/3/3}">3</a></li>
                        <li class="page-item">
                            <a class="page-link" th:href="@{/Goods/list/{currentPage}/3(currentPage = ${currentPage}+1)}">下一页</a>
                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>



    <script>

        function addGoods(){
            window.location.href = "/Goods/toAdd"
        }

    </script>
</body>
</html>